package com.mini.constant;

/**
 * Created by ajGeGe
 *
 * @Description 全局状态标志
 */
public enum YN {

    YES("yes", "是", 1),
    NO("no", "否", 0);

    YN(String info, String tips, int code) {
        this.info = info;
        this.tips = tips;
        this.code = code;
    }

    public static YN create(Integer code) {
        if (null == code) {
            return null;
        }
        for (YN statusEnum : YN.values()) {
            if (code == statusEnum.getCode()) {
                return statusEnum;
            }
        }
        return null;
    }

    private String info;
    private String tips;
    private Integer code;

    public String getInfo() {
        return info;
    }

    public void setInfo(String info) {
        this.info = info;
    }

    public Integer getCode() {
        return code;
    }

    public void setCode(int code) {
        this.code = code;
    }

    public String getTips() {
        return tips;
    }

    public void setTips(String tips) {
        this.tips = tips;
    }

    public static YN getYesNoStatus(int code) {
        for (YN field : YN.values()) {
            if (code == field.getCode()) {
                return field;
            }
        }
        return null;
    }
}
